﻿@model OrderDetailsModel
@using Nop.Web.Models.Order;
@{
    if (!Model.PrintMode)
    {
        Layout = "~/Views/Shared/_ColumnsOne.cshtml";
    }
    else
    {
        Layout = "~/Views/Shared/_Print.cshtml";
    }
    //title
    Html.AddTitleParts(T("PageTitle.OrderDetails").Text);
}
@if (Model.PrintMode)
{
    <script type="text/javascript">
        $(document).ready(function () {
            window.print();
        });
    </script>
}
<div class="page order-details-page">
    @if (!Model.PrintMode)
    {
        <div class="page-title">
            <h1>@T("Order.OrderInformation")</h1>
            <a href="@Url.RouteUrl("PrintOrderDetails", new { orderId = Model.Id })" target="_blank" class="button-2 print-order-button">@T("Order.Print")</a>
            @if (Model.DisplayPdfInvoice)
            {
                <a href="@Url.RouteUrl("GetOrderPdfInvoice", new { orderId = Model.Id })" class="button-2 pdf-order-button">@T("Order.GetPDFInvoice")</a>
            }
        </div>
    }
    <div class="page-body">
        @Html.Widget("orderdetails_page_top")
        <div class="order-overview">
            <div class="order-number">
                <strong>@T("Order.Order#")@Model.Id</strong>
            </div>
            <div class="order-details">
                <span>@T("Order.OrderDate"): @Model.CreatedOn.ToString("D")</span>
                <span>@T("Order.OrderStatus"): @Model.OrderStatus</span>
            </div>
            <div class="order-total">
                @T("Order.OrderTotal"): <strong>@Model.OrderTotal</strong>
            </div>
            @Html.Widget("orderdetails_page_overview")
        </div>
        <div class="order-details-area">
            <table>
                <tbody>
                    <tr>
                        <td>
                            <ul class="billing-info">
                                <li class="title">
                                    <strong>
                                        @T("Order.BillingAddress")</strong>
                                </li>
                                <li class="name">
                                    @Model.BillingAddress.FirstName @Model.BillingAddress.LastName
                                </li>
                                <li class="email">
                                    @T("Order.Email"): @Model.BillingAddress.Email
                                </li>
                                @if (Model.BillingAddress.PhoneEnabled)
                                {
                                    <li class="phone">
                                        @T("Order.Phone"): @Model.BillingAddress.PhoneNumber
                                    </li>
                                }
                                @if (Model.BillingAddress.FaxEnabled)
                                {
                                    <li class="fax">
                                        @T("Order.Fax"): @Model.BillingAddress.FaxNumber
                                    </li>
                                }
                                @if (Model.BillingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.BillingAddress.Company))
                                {
                                    <li class="company">
                                        @Model.BillingAddress.Company
                                    </li>
                                }
                                @if (Model.BillingAddress.StreetAddressEnabled)
                                {
                                    <li class="address1">
                                        @Model.BillingAddress.Address1
                                    </li>
                                }
                                @if (Model.BillingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.BillingAddress.Address2))
                                {
                                    <li class="address2">
                                        @Model.BillingAddress.Address2
                                    </li>
                                }
                                @if (Model.BillingAddress.CityEnabled ||
                            Model.BillingAddress.StateProvinceEnabled ||
                            Model.BillingAddress.ZipPostalCodeEnabled)
                                {
                                    <li class="city-state-zip">
                                        @if (Model.BillingAddress.CityEnabled)
                                        {
                                            @Model.BillingAddress.City
                                        }
                                        @if (Model.BillingAddress.CityEnabled && (Model.BillingAddress.StateProvinceEnabled || Model.BillingAddress.ZipPostalCodeEnabled))
                                        {
                                            <text>,</text>
                                        }
                                        @if (Model.BillingAddress.StateProvinceEnabled)
                                        {
                                            @Model.BillingAddress.StateProvinceName
                                        }
                                        @if (Model.BillingAddress.ZipPostalCodeEnabled)
                                        {
                                            @Model.BillingAddress.ZipPostalCode
                                        }
                                    </li>
                                }
                                @if (Model.BillingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.BillingAddress.CountryName))
                                {
                                    <li class="country">
                                        @Model.BillingAddress.CountryName
                                    </li>
                                }
                                @if (!String.IsNullOrEmpty(Model.VatNumber))
                                {
                                    <li class="vat">
                                        <span class="vat-label">
                                            <strong>@T("Order.VATNumber")</strong>
                                        </span>
                                        <span class="vat-value">
                                            @Model.VatNumber
                                        </span>
                                    </li>
                                }
                                @if (!String.IsNullOrEmpty(Model.PaymentMethod))
                                {
                                    <li class="title">
                                        <strong>@T("Order.PaymentMethod")</strong>
                                    </li>
                                    <li class="payment-method">
                                        @Model.PaymentMethod
                                    </li>
                                    if (!Model.PrintMode && Model.CanRePostProcessPayment)
                                    {
@*Completing payment support (for redirection payment methods)*@
                                    <li class="repost">
                                        @using (Html.BeginRouteForm("OrderDetails", FormMethod.Post))
                                        {
                                            <input type="submit" name="repost-payment" value="@T("Order.CompletePayment")" class="button-1 re-order-button" />
                                            <p class="hint">
                                                <em>@T("Order.CompletePayment.Hint")</em>
                                            </p>
                                        }
                                    </li>
                                    }
                                }
                                @if (Model.DisplayPurchaseOrderNumber)
                                {
                                    <li class="po">
                                        <span class="po-label">
                                            <strong>@T("Order.PurchaseOrderNumber")</strong>
                                        </span>
                                        <span class="po-value">
                                            @Model.PurchaseOrderNumber
                                        </span>
                                    </li>
                                }
                            </ul>
                        </td>
                        @if (Model.IsShippable)
                        {
                            <td>

                                <ul class="shipping-info">
                                    <li class="title">
                                        <strong>
                                            @T("Order.ShippingAddress")</strong>
                                    </li>
                                    <li class="name">
                                        @Model.ShippingAddress.FirstName @Model.ShippingAddress.LastName
                                    </li>
                                    <li class="email">
                                        @T("Order.Email"): @Model.ShippingAddress.Email
                                    </li>
                                    @if (Model.ShippingAddress.PhoneEnabled)
                                    {
                                        <li class="phone">
                                            @T("Order.Phone"): @Model.ShippingAddress.PhoneNumber
                                        </li>
                                    }
                                    @if (Model.ShippingAddress.FaxEnabled)
                                    {
                                        <li class="fax">
                                            @T("Order.Fax"): @Model.ShippingAddress.FaxNumber
                                        </li>
                                    }
                                    @if (Model.ShippingAddress.CompanyEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.Company))
                                    {
                                        <li class="company">
                                            @Model.ShippingAddress.Company
                                        </li>
                                    }
                                    @if (Model.ShippingAddress.StreetAddressEnabled)
                                    {
                                        <li class="address1">
                                            @Model.ShippingAddress.Address1
                                        </li>
                                    }
                                    @if (Model.ShippingAddress.StreetAddress2Enabled && !String.IsNullOrEmpty(Model.ShippingAddress.Address2))
                                    {
                                        <li class="address2">
                                            @Model.ShippingAddress.Address2
                                        </li>
                                    }
                                    @if (Model.ShippingAddress.CityEnabled ||
                                     Model.ShippingAddress.StateProvinceEnabled ||
                                     Model.ShippingAddress.ZipPostalCodeEnabled)
                                    {
                                        <li class="city-state-zip">
                                            @if (Model.ShippingAddress.CityEnabled)
                                            {
                                                @Model.ShippingAddress.City
                                            }
                                            @if (Model.ShippingAddress.CityEnabled && (Model.ShippingAddress.StateProvinceEnabled || Model.ShippingAddress.ZipPostalCodeEnabled))
                                            {
                                                <text>,</text>
                                            }
                                            @if (Model.ShippingAddress.StateProvinceEnabled)
                                            {
                                                @Model.ShippingAddress.StateProvinceName
                                            }
                                            @if (Model.ShippingAddress.ZipPostalCodeEnabled)
                                            {
                                                @Model.ShippingAddress.ZipPostalCode
                                            }
                                        </li>
                                    }
                                    @if (Model.ShippingAddress.CountryEnabled && !String.IsNullOrEmpty(Model.ShippingAddress.CountryName))
                                    {
                                        <li class="country">
                                            @Model.ShippingAddress.CountryName
                                        </li>
                                    }
                                    <li class="title">
                                        <strong>@T("Order.ShippingMethod")</strong>
                                    </li>
                                    <li class="shipping-method">
                                        @Model.ShippingMethod
                                    </li>
                                </ul>
                            </td>
                        }
                    </tr>
                </tbody>
            </table>
        </div>
        @Html.Widget("orderdetails_page_beforeproducts")
        @if (Model.Items.Count > 0)
        {
            <div class="section products">
                <div class="title">
                    <strong>@T("Order.Product(s)")</strong>
                </div>
                <table class="data-table">
                    <colgroup>
                        @if (Model.ShowSku)
                        {
                            <col width="1" />
                        }
                        <col />
                        <col />
                        <col />
                        <col />
                    </colgroup>
                    <thead>
                        <tr>
                            @if (Model.ShowSku)
                            {
                                <th class="a-center">
                                    @T("Order.Product(s).SKU")
                                </th>
                            }
                            <th class="a-center">
                                @T("Order.Product(s).Name")
                            </th>
                            <th class="a-center">
                                @T("Order.Product(s).Price")
                            </th>
                            <th class="a-center">
                                @T("Order.Product(s).Quantity")
                            </th>
                            <th class="a-center">
                                @T("Order.Product(s).Total")
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.Items)
                        {
                            <tr>
                                @if (Model.ShowSku)
                                {
                                    <td class="a-left">
                                        @item.Sku
                                    </td>
                                }
                                <td class="a-left">
                                    @if (!Model.PrintMode)
                                    {
                                        <em><a href="@Url.RouteUrl("Product", new { SeName = item.ProductSeName })" title="View details">@item.ProductName</a></em>
                                    }
                                    else
                                    {
                                        @item.ProductName
                                    }
                                    @if (!String.IsNullOrEmpty(item.AttributeInfo))
                                    {
                                        <div class="attributes">
                                            @Html.Raw(item.AttributeInfo)
                                        </div>
                                    }
                                </td>
                                <td class="a-right">
                                    @item.UnitPrice
                                </td>
                                <td class="a-center">
                                    @item.Quantity
                                </td>
                                <td class="a-right">
                                    @item.SubTotal
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
                @if (!String.IsNullOrEmpty(Model.CheckoutAttributeInfo))
                {
                    <div class="checkout-attributes">
                        @Html.Raw(Model.CheckoutAttributeInfo)
                    </div>
                }
                @if (!Model.PrintMode)
                {
                    <div class="actions">
                        @if (Model.IsReOrderAllowed)
                        {
                            <input type="button" value="@T("Order.Reorder")" class="button-1 re-order-button" onclick="setLocation('@Url.RouteUrl("ReOrder", new { orderId = Model.Id })    ')" />
                        }
                        @if (Model.IsReturnRequestAllowed)
                        {
                            <text>&nbsp; &nbsp; &nbsp;</text>
                            <input type="button" value="@T("Order.ReturnItems")" class="button-2 return-items-button" onclick="setLocation('@Url.RouteUrl("ReturnRequest", new { orderId = Model.Id })    ')" />
                        }
                    </div>
                }
            </div>
        }
        @Html.Widget("orderdetails_page_afterproducts")
        <div class="total-info">
            <table class="cart-total">
                <tbody>
                    <tr>
                        <td class="cart-total-left">
                            <strong>
                                @T("Order.SubTotal"):</strong>
                        </td>
                        <td class="cart-total-right">
                            <span class="nobr">
                                @Model.OrderSubtotal
                            </span>
                        </td>
                    </tr>
                    @if (!string.IsNullOrEmpty(Model.OrderSubTotalDiscount))
                    {
                        <tr>
                            <td class="cart-total-left">
                                <strong>
                                    @T("Order.SubTotalDiscount"):</strong>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.OrderSubTotalDiscount
                                </span>
                            </td>
                        </tr>
                    }
                    @if (Model.IsShippable)
                    {
                        <tr>
                            <td class="cart-total-left">
                                <strong>
                                    @T("Order.Shipping"):</strong>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.OrderShipping
                                </span>
                            </td>
                        </tr>
                    }
                    @if (!string.IsNullOrEmpty(Model.PaymentMethodAdditionalFee))
                    {
                        <tr>
                            <td class="cart-total-left">
                                <strong>
                                    @T("Order.PaymentMethodAdditionalFee"):</strong>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.PaymentMethodAdditionalFee
                                </span>
                            </td>
                        </tr>
                    }
                    @if (Model.DisplayTaxRates && Model.TaxRates.Count > 0)
                    {
                        foreach (var taxRate in Model.TaxRates)
                        {
                        <tr>
                            <td class="cart-total-left">
                                <strong>
                                    @string.Format(T("Order.TaxRateLine").Text, taxRate.Rate):</strong>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @taxRate.Value
                                </span>
                            </td>
                        </tr>
                        }
                    }
                    @if (Model.DisplayTax)
                    {
                        <tr>
                            <td class="cart-total-left">
                                <strong>
                                    @T("Order.Tax"):</strong>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.Tax
                                </span>
                            </td>
                        </tr>
                    }
                    @if (!string.IsNullOrEmpty(Model.OrderTotalDiscount))
                    {
                        <tr>
                            <td class="cart-total-left">
                                <strong>
                                    @T("Order.TotalDiscount"):</strong>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.OrderTotalDiscount
                                </span>
                            </td>
                        </tr>
                    }
                    @if (Model.GiftCards.Count > 0)
                    {
                        foreach (var gc in Model.GiftCards)
                        {
                        <tr>
                            <td class="cart-total-left">
                                <strong>
                                    @string.Format(T("Order.GiftCardInfo").Text, gc.CouponCode):</strong>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @gc.Amount
                                </span>
                            </td>
                        </tr>
                        }
                    }
                    @if (Model.RedeemedRewardPoints > 0)
                    {
                        <tr>
                            <td class="cart-total-left">
                                <strong>@string.Format(T("Order.RewardPoints").Text, Model.RedeemedRewardPoints):</strong>
                            </td>
                            <td class="cart-total-right">
                                <span class="nobr">
                                    @Model.RedeemedRewardPointsAmount
                                </span>
                            </td>
                        </tr>
                    }
                    <tr>
                        <td class="cart-total-left">
                            <strong>
                                @T("Order.OrderTotal"):</strong>
                        </td>
                        <td class="cart-total-right">
                            <span class="nobr"><strong>
                                @Model.OrderTotal</strong>
                            </span>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        @if (!Model.PrintMode)
        {
            if (Model.Shipments.Count > 0)
            {
            <div class="section shipments">
                <div class="title">
                    <strong>@T("Order.Shipments")</strong>
                </div>
                <table class="data-table">
                    <colgroup>
                        <col width="1" />
                        <col />
                        <col />
                        <col />
                        <col />
                    </colgroup>
                    <thead>
                        <tr>
                            <th class="a-center">
                                @T("Order.Shipments.ID")
                            </th>
                            <th class="a-center">
                                @T("Order.Shipments.TrackingNumber")
                            </th>
                            <th class="a-center">
                                @T("Order.Shipments.ShippedDate")
                            </th>
                            <th class="a-center">
                                @T("Order.Shipments.DeliveryDate")
                            </th>
                            <th class="a-center">
                                @T("Order.Shipments.ViewDetails")
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.Shipments)
                        {
                            <tr>
                                <td class="a-left">
                                    @item.Id.ToString()
                                </td>
                                <td class="a-left">
                                    @item.TrackingNumber
                                </td>
                                <td class="a-left">
                                    @if (item.ShippedDate.HasValue)
                                    {
                                        @item.ShippedDate.Value.ToString("D")
                                    }
                                    else
                                    {
                                        @T("Order.Shipments.ShippedDate.NotYet")
                                    }
                                </td>
                                <td class="a-left">
                                    @if (item.DeliveryDate.HasValue)
                                    {
                                        @item.DeliveryDate.Value.ToString("D")
                                    }
                                    else
                                    {
                                        @T("Order.Shipments.DeliveryDate.NotYet")
                                    }
                                </td>
                                <td class="a-center">
                                    <a href="@Url.RouteUrl("ShipmentDetails", new { shipmentId = item.Id })" title="@T("Order.Shipments.ViewDetails")">@T("Order.Shipments.ViewDetails")</a>
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            }
        }
        @if (!Model.PrintMode)
        {
            if (Model.OrderNotes.Count > 0)
            {
            <div class="section order-notes">
                <div class="title">
                    <strong>@T("Order.Notes")</strong>
                </div>
                <table class="data-table">
                    <colgroup>
                        <col />
                        <col />
                    </colgroup>
                    <thead>
                        <tr>
                            <th class="a-center">
                                @T("Order.Notes.CreatedOn")
                            </th>
                            <th class="a-center">
                                @T("Order.Notes.Note")
                            </th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach (var item in Model.OrderNotes)
                        {
                            <tr>
                                <td class="a-left">
                                    @item.CreatedOn.ToString()
                                </td>
                                <td class="a-left">
                                    @Html.Raw(item.Note)
                                </td>
                            </tr>
                        }
                    </tbody>
                </table>
            </div>
            }
        }
        @Html.Widget("orderdetails_page_bottom")
    </div>
</div>
